package com.linkelee.consumer.configuration;


import com.linkelee.MqConsumerBuilder;
import com.linkelee.properties.RpcMqConsumerProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnSingleCandidate(ConnectionFactory.class)
@EnableConfigurationProperties(RpcMqConsumerProperties.class)
@AutoConfigureAfter(RabbitAutoConfiguration.class)
@Slf4j
public class MqConsumerAutoConfiguration {

    @Bean
    public MqConsumerBuilder mqConsumerBuilder() throws Exception{
        return MqConsumerBuilder.builder().build();
    }

}
